package com.example.demo.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;


@Configuration
public class FileHandleConfig extends WebMvcConfigurationSupport {

    @Value("${file.image.address}")
    private String imageAddress;

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        //通过image访问本地的图片
        registry.addResourceHandler("/image/**").addResourceLocations("file:" + imageAddress);
    }
}
